﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using KxApp.Views;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace KxApp.ViewModels
{
    //[ExposedService(Lifetime.Singleton)]
    public partial class LoginViewModel : ObservableObject
    {
        public MainView? Mv { get; set; }

        public LoginViewModel()
        {
            Pwd = "123";
            UName = "admin";
        }

        [RelayCommand]
        public void Login(Window window)
        {
            window.Close();
            Mv?.Show();
        }

        [RelayCommand]
        public void Close(Window window)
        {
            window.Close();
            Mv?.Close();
        }

        [RelayCommand]
        public void TBtnCmd(bool isChecked)
        {
            if (isChecked)
            {
                TxtVis = Visibility.Visible;
                PwdVis = Visibility.Hidden;
            }
            else
            {
                TxtVis = Visibility.Hidden;
                PwdVis = Visibility.Visible;
            }
        }

        Grid grid = new();

        [RelayCommand]
        public void LoadGrid(Grid o)
        {

            grid = o;
        }

        //MouseButtonEventArgs
        public void MouseMove(object o, MouseEventArgs e)
        {
            var a = e.GetPosition(grid);
        }

        [ObservableProperty]
        private string pwd = string.Empty;

        [ObservableProperty]
        private string uName = string.Empty;

        [ObservableProperty]
        private Visibility pwdVis = Visibility.Visible;

        [ObservableProperty]
        private Visibility txtVis = Visibility.Hidden;
    }
}
